package com.b2.controller.wx;

import com.b2.pojo.dto.addClassDto;
import com.b2.pojo.entity.Class;
import com.b2.pojo.entity.Parent;
import com.b2.pojo.vo.ClassOfDirectorVo;
import com.b2.pojo.vo.ClassOfParentVo;
import com.b2.pojo.vo.ClassOfTeacherVo;
import com.b2.result.Result;
import com.b2.service.ClassService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/wx/Class")
@Slf4j
@Api(tags = "微信班级相关接口")
@CrossOrigin
public class ClassController {

    @Autowired
    ClassService classService;

    //幼儿园园长添加幼儿园
    @PostMapping("addClass")
    @ApiOperation("幼儿园园长添加幼儿园")
    public Result addclass(@RequestBody addClassDto classDto){
        Class addclass = classService.addclass(classDto);
        return Result.success(addclass);
    }
    //家长退出班级
    @DeleteMapping("parentExitClass")
    @ApiOperation("家长退出班级")
    public Result parent_exit_class(Long id){
        classService.parent_exit_class(id);
        return Result.success(id);
    }
    //园长删除班级
    @DeleteMapping("deleteClass")
    @ApiOperation("园长删除班级")
    public Result deleteclass(Long id){
        classService.deleteclass(id);
        return Result.success(id);
    }

    //园长获取班级信息
    @GetMapping ("director/getclass")
    @ApiOperation("园长获取班级信息")
    Result<List<ClassOfDirectorVo>> getclass1(){
        List<ClassOfDirectorVo> lists=classService.getclass1();
        return Result.success(lists);
    }
    //老师获取班级信息
    @GetMapping ("tezcher/getclass")
    @ApiOperation("老师获取班级信息")
    Result<List<ClassOfTeacherVo>> getclass2(){
        List<ClassOfTeacherVo> lists=classService.getclass2();
        return Result.success(lists);
    }
    //家长获取班级信息
    @GetMapping ("parent/getclass")
    @ApiOperation("家长获取班级信息")
    Result<List<ClassOfParentVo>> getclass3(){
        List<ClassOfParentVo> lists=classService.getclass3();
        return Result.success(lists);
    }
    //获取班级成员
    @GetMapping ("getParentInfomation")
    @ApiOperation("获取班级成员")
    Result<List<Parent>> getParentInfomation(Long id){
        List<Parent> lists=classService.getParentInfomation(id);
        return Result.success(lists);
    }

    //老师进入新的班级
    @PostMapping("TeacherToClass")
    @ApiOperation("老师进入新的班级")
    public Result TeacherToClass(String code){
        classService.TeacherToClass(code);
        return Result.success();
    }
    //家长进入新得班级
    @PostMapping("ParentToClass")
    @ApiOperation("家长进入新得班级")
    public Result ParentToClass(String code){
        classService.ParentToClass(code);
        return Result.success();
    }
}
